//////////////////////////////////////////////////////////////////////////////////////////
/////
/// This is part of a collection of libraries developed by Asaf Shelly
/// More about Asaf Shelly: http://Asaf.Shelly.co.il
/// More about the libraries: http://AsyncOp.com
///
/// You are permitted to use, copy, publish, execute and redistribute
/// this code and library free of charge for the duration of the copyright 
//
//////////////////////////////////////////////////////////////////////////////////////////
///// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
///// DEALINGS IN THE SOFTWARE
//////////////////////////////////////////////////////////////////////////////////////////
/////
/// For more details and an explicit legal permission you can contact me
/// directly:
/// Asaf Shelly
/// OpenSource@Shelly.co.il
/// http://AsyncOp.com
/// http://Asaf.Shelly.co.il
///
/// This code has been under development for over ten years and is still
/// updated occasionally.
/// It is recommended that you go online to find updates and fixed.
/// It is also recommended that you add a link in your code that is using
/// this or part of this source for future reference.
/// 
/// If you have any bug fixes, known bugs, updates, extensions, and other
/// comments feel free to post to the website or contact me directly.
//

// standard windows messagebox and string output by Asaf shelly 10/2/2000

// ToDo
// Go over all the functions to make sure that RequestLength(X) is not limited to less than X because of LimitLength. in this case RequestLength(X) will not return zero, but also not return the needed length.
// NOTES :
// 14/10/2003 : You can know file<<file completed successfuly by checking string to be empty.

 #ifndef INCLUDE_FILE__stdTell_h__
   #define INCLUDE_FILE__stdTell_h__

   #include <STDIO.h>
   #include <stdlib.h>
   #include <windows.h>
   #include <ShlObj.h>
   #include <AdvStr.h>

   #include <DebugMode.h>


   #ifndef __LINKAGE_WMD
     #define __LINKAGE_WMD
     #define __LINKAGE_WMD_TYPE 'L'
   #endif

   #if (__LINKAGE_WMD_TYPE=='L')
     #include <Thread.h>
   #else
     #include <Thread.h>
   #endif
              
  #ifdef _MANAGED // MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - 
   #using <MSCorLib.dll>
  #endif _MANAGED // MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - 

namespace StdTell_namespace
{

  #ifdef _MANAGED // MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - 
   using namespace System;
  #endif _MANAGED // MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - 


 class __LINKAGE_WMD Teller
  {
   private:
   protected:
      struct IndexingData
       {
        Teller* lastIndexedTeller;
        unsigned long lastIndexedItem;
        unsigned long lastIndexedPos;
        unsigned long lastIndexedLen;
        unsigned long lastIndexedTextLen;
        unsigned long lastIndexedTextLen2;
        char* lastIndexedText;
        char* lastIndexedText2;
       };
             IndexingData* pIndexingData;
             char* msgOut;
             unsigned long msgLen;
             unsigned long msgLenLimit;
             char* Anouncement;
             void* pParent;
             int intType;
             unsigned int messageBoxFlags;
             void __stdcall DataRefresh();
             char* __stdcall StringAlloc();
             int __stdcall Init();
             unsigned long __stdcall GetFileData();     // ret bytes read.
             unsigned long __stdcall GetWebData();      // ret bytes read.
             int __stdcall TellMedia_MessageBox();
             int __stdcall TellMedia_Debugger();
             int __stdcall TellMedia_File();
             int __stdcall TellMedia_Web();
             Teller* lastIndexedTeller;
             unsigned long lastIndexedItem;
             unsigned long lastIndexedPos;
             unsigned long lastIndexedLen;
             unsigned long lastIndexedTextLen;
             unsigned long lastIndexedTextLen2;
             char* lastIndexedText;
             char* lastIndexedText2;
             bool __stdcall ValidateIndexes(long offset=0);
             bool __stdcall OffsetIndexes(long offset);
             void __stdcall FindIndexed(char* strs, char* stre);    // str start, str end.
             char* __stdcall FindIndexed(unsigned long count);
             unsigned long flags;
          enum ENUM_FLAGS { FLAG_NON=0x0, FLAG_TEMPORARY_MAY_SWAP=0x1, FLAG_INDEXING_REMOVEHEADER=0x2, FLAG_INDEXING_INSERTTAIL=0x4 };
             inline void FlagsSetTemporaryMaySwap() { if (POK(this)) flags|=FLAG_TEMPORARY_MAY_SWAP; }
             inline bool FlagsGetTemporaryMaySwap() { if (PE(this)) return(false);  else return(flags&FLAG_TEMPORARY_MAY_SWAP); }
             void __stdcall CleanupTemporaryAfterUse();
   public:
          enum OutMedia { MEDIA_BLANK=0, MEDIA_MESSAGEBOX=1, MEDIA_DEBUGGER=2, MEDIA_FILE=3, MEDIA_WEB=4 };
             inline bool MaySwap() { if (GOOD(this)) { FlagsSetTemporaryMaySwap(); return(true); }  else return(false); }    // Allows swap of internal data instead of copy when using copy constructor.
             typedef int (__stdcall* Type_TellMedia_FunctionPtr)(char* Msg, char* anounce);
             inline Teller& IndexingNoHeader()  { flags|=FLAG_INDEXING_REMOVEHEADER; return(*this); }
             inline Teller& IndexingUseHeader(bool use=true) { if (use) flags&=(~FLAG_INDEXING_REMOVEHEADER); else IndexingNoHeader(); return(*this); }
             inline Teller& IndexingNoTail()    { flags&=(~FLAG_INDEXING_INSERTTAIL); return(*this); }
             inline Teller& IndexingUseTail(bool use=true)   { if (use) flags|=FLAG_INDEXING_INSERTTAIL; else IndexingNoTail(); return(*this); }
             inline Teller& IndexingUseNone()   { IndexingNoHeader(); IndexingNoTail(); return(*this); }
             inline Teller& IndexingUseBoth(bool use=true)   { IndexingUseHeader(use); IndexingUseTail(use); return(*this); }
             unsigned long __stdcall IndexOffset();                       // -1=not found, 0=first. using last index used, faster, assuming index was already found.
             unsigned long __stdcall IndexOffset(int startIndex);         // -1=not found, 0=first.
             unsigned long __stdcall IndexLength();                       // 0=not found, 1=first. using last index used, faster, assuming index was already found.
             unsigned long __stdcall IndexLength(int startIndex);         // 0=not found, 1=first. - Find the length of the section.
             unsigned long __stdcall TrimFromIndex(int startIndex=1);     // ret shorting len, 0=fail.
             unsigned long __stdcall TrimAfterIndex(int startIndex=1);    // ret shorting len, 0=fail.
             unsigned long __stdcall TrimToIndex(int startIndex=1);       // ret shorting len, 0=fail.
             unsigned long __stdcall TrimTillIndex(int startIndex=1) { return(TrimToIndex(startIndex)); }
             unsigned long __stdcall TrimBeforeIndex(int startIndex=1);   // ret shorting len, 0=fail.
             bool __stdcall ValidIndex(int index);                        // true = still within borders. false = out of bounds.
             int __stdcall IndexingNext(int &index);                      // advances index from 0 to last index, and then goes to -1 to get the last object, and then MAXINT to stop. retval is index.
             Teller& __stdcall RemoveIndex(int startIndex);
             Teller& __stdcall RemoveIndex() { return(RemoveIndex(lastIndexedItem)); }
             Teller& __stdcall ReplaceIndex(int startIndex, char* str);
             Teller& __stdcall ReplaceIndex(char* str) { return(ReplaceIndex(lastIndexedItem,str)); }
             Teller& __stdcall RefreshIndex();
             Teller& __stdcall IndexRefresh() { return(RefreshIndex()); }
   protected:
             OutMedia outMedia;
             inline bool IndexingRemovingHead()    { return(flags&FLAG_INDEXING_REMOVEHEADER); }
             inline bool IndexingInsertingTail()   { return(flags&FLAG_INDEXING_INSERTTAIL); }
          static char* __stdcall Ptrc_FindZz(const char* src, const char** arr, int count, bool first=true);  // retval is any item found, 0=non. char strzz[]="item1\0item2\0item3\0\0"; // may use ascii 255 instead of 0. first : if true, returns item that is not the start of msgOut.
          static bool __stdcall Ptrc_ParseStrzz(const char* strzz, char**& arr, int& count, char*& copy=(*(char**)NULL));    // Note to delete arr and copy. Note copy assumed empty. if copy, dest is copy else dest is strzz. dest has strzz with dNullTerminator replaced with \0. or return(true) arr holds an array or all sz inside dest (not strzz!!). count is the number of items in arr which is all items +1 for end, so we can know the len os all items.
          static bool __stdcall Ptrc_ParseStrzz_Cleaup(char**& arr, int& count, char*& copy);                 // delete arr and copy using local memory managment. do other cleanup.
   public:
          class __LINKAGE_WMD IntType { public: int val; IntType(int v); };
          class __LINKAGE_WMD StrRet { public: int val; StrRet(int v); };
          class __LINKAGE_WMD StrAdd { public: int val; StrAdd(int v); };
          class __LINKAGE_WMD Rotator
           { public: int val; int count; Rotator(int v); Rotator& operator()(int i); };
          class __LINKAGE_WMD Insertor
           {
            public:
                   int val;
                   int count;
                   Insertor(int v);
                   Insertor& operator()(int i);
                   Insertor& operator()(int ch, int t);
           };
          class __LINKAGE_WMD String
           {
            private:
            protected:
                      char* str;
                      wchar_t* wstr;
                      int len;
                      int buffLen;                          // note that is number of chars not sizeof buffer.
            public:
                      String();
                      String(const char* ptr);              // allocate.
                      String(const wchar_t* wptr);          // allocate.
                      String(Teller& rtl);                  // swap if flagged, else allocate.
                      String(String &string);               // swap.
                   virtual ~String();
                      char* __stdcall Str();
                      char* __stdcall Str(const char* ptr);         // allocate.
                      wchar_t* __stdcall Str(const wchar_t* wptr);  // allocate.
                      char* __stdcall Str(Teller& rtl);             // swap if flagged, else allocate.
                      char* __stdcall Str(String &string);          // swap.
                      wchar_t* __stdcall WStr();
                      int __stdcall Len();
                   template <class tpltType> Teller::String& operator=(tpltType &obj)
                       { Str(obj); return(*this); }
                   friend class String;
                   friend class Teller;
                      bool __stdcall operator ==(const char* ptr);      // MADDOG Teller needs ones too.
                      bool __stdcall operator ==(const wchar_t* wptr);
                      bool __stdcall operator ==(Teller::String& rstr);
                      bool __stdcall operator !=(const char* ptr);
                      bool __stdcall operator !=(const wchar_t* wptr);
                      bool __stdcall operator !=(Teller::String& rstr);
                      __stdcall operator char* ();
  #ifdef DSTRING_H // VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL
                      char* __stdcall Str(AnsiString& astr) { return(Str(astr.c_str())); }
  #endif // VCL_H // VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL
           };
          friend class String;
          static IntType dec;    // each on it's own line for MSVC bug.
          static IntType hex;
          static IntType oct;
          static IntType bin;
          static IntType bol;
          static StrRet strRet;      // replaced 29/11/2003; ((// MADDOG replace this name 13-01-2003))
             StrAdd LastError;
          static Rotator ROL;
          static Rotator ROR;
          static Insertor blank;
          static Insertor insert;
          static char dNullTerminator[2];    // { 255,\0 }
             unsigned long StrMaxLen;
             unsigned long __stdcall FileReload();
             unsigned long __stdcall ReloadFile() { return(FileReload()); }
             Teller(const char* info, OutMedia oMedia);
             Teller();
             Teller(Teller& tll);         // copy constructor
             Teller(String& rts);         // copy constructor
  #if ((!defined(__BORLANDC__))||(__BORLANDC__>=0x0550)) // otherwise as global function at the end.
          template <class tpltType> Teller(tpltType param): outMedia(MEDIA_BLANK),intType(0),LastError(1),StrMaxLen(0)
              {
               Init();
               (*this)<<param;
              }
  #endif
             ~Teller();
             char* __stdcall Clean();          // NOTE that it returns an empty string if successfull.
             char* __stdcall Clear() { return(Clean()); }
             bool __stdcall RemoveFile();      // 1=OK;
             Teller __stdcall Announcement();
             Teller __stdcall Announcement(Teller tll);
             void* __stdcall Parent();                              // if messageBox parent is hwnd. 
             void* __stdcall Parent(void* parent);
             unsigned long __stdcall Len();                            // retval is strlen();
             unsigned long __stdcall Length() { return(Len()); }
             unsigned long __stdcall WLen();                           // retval is the wide char len;
             unsigned long __stdcall WLength() { return(WLen()); }
             unsigned long __stdcall WideLength() { return(WLen()); }
             unsigned long __stdcall WideLen() { return(WLen()); }
             unsigned long __stdcall SetLength(unsigned long newLen);  // ret newlen
             unsigned long __stdcall ShortenBy(unsigned long trimLen); // ret newlen
             unsigned long __stdcall BufferLength();                   // buffer allocated.
             unsigned long __stdcall BufferLimit();                    // maximum buffer allowed.
             char*         __stdcall Str();
             String        __stdcall AsString();
             unsigned long __stdcall LimitLength(unsigned long len);   // ret prev limit.
             unsigned long __stdcall RequestLength(unsigned long len); // of string, not buffer. NOTE that retval could be => by buffer allocation units. ret : max length on success or 0 on fail, even if a smaller buffer exists.
             unsigned long __stdcall AddBuffer(unsigned long len, int fillCh);  // add buffer and fill all bytes with specific char at int. retval is bytes added. 
             unsigned long __stdcall Remove(const int ch);          // retval is intances removed.
             unsigned long __stdcall RemoveWhite();                 // retval is intances removed.
             bool          __stdcall HasWhite();                    // retval is true if there is any white char in the string.
             unsigned long __stdcall NextWhite(int start);          // retval is the index of the next white char. first=0. last=msgLen-1, non=msgLen;
             unsigned long __stdcall NextNonWhite(int start);       // retval is the index of the next non white char. first=0. last=msgLen, non=msgLen;
             unsigned long __stdcall RemoveWhiteEnd();              // retval is intances removed.
             unsigned long __stdcall RemoveWhiteHead();             // retval is intances removed.
             unsigned long __stdcall Replace(const int old, const int ch);   // retval is intances replaced.
             unsigned long __stdcall Count(const int ch);           // retval is intances found.
             unsigned long __stdcall Count(const char* str);        // retval is intances found.
             unsigned long __stdcall Count(Teller& tll);            // retval is intances found.
             unsigned long __stdcall Appears(const char* str);      // retval is whether str appears in the string, and it's position. first=1, 0=non.
             unsigned long __stdcall Appears(Teller& tlr);          // retval is whether tlr appears in the string, and it's position. first=1, 0=non.
             unsigned long __stdcall AppearsAfter(const char* str, const unsigned long pos);   // retval is same as Appears(), pos is of same kind.
             unsigned long __stdcall AppearsAfter(Teller& tlr, const unsigned long pos);    // retval is same as Appears(), pos is of same kind.
             unsigned long __stdcall AddStrN(const char* str, const unsigned long len);     // retval is number of chars copied.
             unsigned long __stdcall AddStrN(Teller& tlr, const unsigned long len);         // retval is number of chars copied.
             unsigned long __stdcall AddStrTill(const char* str, const char* till);         // copy str and stop when getting to the location in memory stored by till.
             unsigned long __stdcall AddStrTill(Teller& tlr, const char* till);             // copy tlr.Str() and stop when getting to the location in memory stored by till.
             bool __stdcall BeginsWith(const char* str);            // retval is whether the string begins with str. RUNTIME over Appears() or Find().
             bool __stdcall BeginsWith(Teller& tlr);                // retval is whether the string begins with tlr. RUNTIME over Appears() or Find().
             bool __stdcall EndsWith(const char* str);              // retval is whether the string ends with str.
             bool __stdcall EndsWith(Teller& tlr);                  // retval is whether the string ends with tlr.
             char* __stdcall Find(const char* str);                 // retval is found, 0=non.
             char* __stdcall FindEnd(const char* str);              // retval is char after string found, 0=non.
             char* __stdcall FindFrom(const char* str, const char* start);         // retval is found, 0=non. start is a location in the string, returned from Find().
             char* __stdcall FindEndFrom(const char* str, const char* start);      // retval is char after string found, 0=non.
             char* __stdcall FindZz(const char* strzz, bool first=true);           // retval is any item found, 0=non. char strzz[]="item1\0item2\0item3\0\0"; // may use ascii 255 instead of 0. first : if true, returns item that is not the start of msgOut. MADDOG RT warning : strzz is copied and scanned for dNullTerminator.
             Teller __stdcall AllBefore(const char* str);           // retval is the string untill and not including str. 
             unsigned long __stdcall Replace(const char* find, const char* ins);   // retval is intances replaced.
             Teller::String __stdcall Matching(char* open, char* close);           // ++count for open, --count for close, ret when count goes back to 0. Teller(tll.Find("{")).Matching("{","}").Length(); ((("}"to even {} count inside class scope for dumb parser))) // retval altered from Teller to Teller::String so that VC++ 6 won't find it hard to find a closing '}'.
             Teller& __stdcall Sectionize(const char* strzz);       // Own string modified. retval is the original string devided into sections specified by strzz (see FindZz), seperated using dNullTerminator.
             unsigned long __stdcall DoubleNullLength();            // size of a double null strings buffer.
             unsigned long __stdcall DoubleNullMaxStrlen();         // size of the longest string in a double null strings.
             char* __stdcall DoubleNullString(char* dest);          // copies the string replacing '\n' with null, terminating with double null.
             Teller& __stdcall DoubleNullString();                  // translating msgOut to double null terminating replacing '\r\n','\r','\n' with dNullTerminator.
             char* __stdcall ToDoubleNullString(char* dest);        // copies the string to a double null destination (replacing dNullTerminator with 0).
             char* __stdcall FromDoubleNullString(char* src);       // copies the string from a double null destination (using dNullTerminator between strings).
             Teller& __stdcall ReadStdin(int count);                // reads 'count' chars from stdin.
             Teller& __stdcall ValidFileName();                     // replaces illigal file name chars with legal ones. NOTE : using ConvertToFileName but adding ('') instead of (') for every (").
          static char* __stdcall SourceSyntax(int ch);              // esc codes for C\++ lang. returning constant static string that will not change. NOTE : ret NULL if not.
             Teller& __stdcall SourceSyntax();                      // esc codes for C\++ lang.
          static int __stdcall FromSourceSyntax(char* ptr);         // esc codes for C\++ lang. return char without '\' or -1. if other than -1 returned then 2 chars have been accounted for in the input string. NOTE that retval is int and needs to be casted to char.
             Teller& __stdcall FromSourceSyntax();                  // esc codes for C\++ lang.
          static long __stdcall HexDigitOfAscii(int ch);            // A to [4][0] -1 for error
          static int __stdcall ValueOfHexDigit(int dig);            // 10 to A -1 for error
          static Teller::String __stdcall HexDigitOfAscii(char* str);  // A... to [4][0] empty for error.
          static Teller::String __stdcall ValueOfHexDigit(char* str);  // [4][0].... to A empty for error.
             int __stdcall AsInt();                                 // ret : integer value of the string keeps goint untill no more digits. ret 0 on fail or no digits.
          inline int __stdcall AsInteger() { return(AsInt()); }     // ret : AsInt();
             Teller __stdcall WhiteRemoved();                       // retval is a copy with white removed.
             Teller __stdcall AsLowerCase();                        // rets a copy with all lower case.
             Teller __stdcall AsUpperCase();                        // rets a copy with all upper case.
             Teller __stdcall HexToAscii();                         // for "30313234" rets temp Teller of "0124"
             Teller __stdcall AsciiToHex();                         // for "0124" rets temp Teller of "30313234"
             Teller __stdcall AsHTMLVisible(bool keepSpaces=false); // internal call to AsHTMLEncoded.
             Teller __stdcall AsHTMLTranslate();                    // internal call to AsHTMLDecoded.
             Teller __stdcall AsHTMLEncoded(bool keepSpaces=false); // rets a copy with HTML reserved tags replaced with the visibility code (eg. "<" to "&lt;"). keepSpaces prevents converting ' ' to &nbsp;
             Teller __stdcall AsHTMLDecoded();                      // rets a copy with HTML reserved tags replacing the visibility code (eg. "<" from "&lt;").
             Teller __stdcall AsHTMLEncodedTag(bool keepSpaces=false); // internal call to AsHTMLEncoded + replacing '\' with "&#47;"
             Teller __stdcall AsHTMLDecodedTag();                      // internal call to AsHTMLDecoded + replacing "&#47;" with '\'
             Teller __stdcall AsURLEncode();                        // rets a new string that is a valid HTTP URL / GET-Post reqeuest. "(" to "%28".
             Teller __stdcall AsURLDecode();                        // rets a new string that is a back translation of valid HTTP URL / GET-Post reqeuest. "%28" to "(".
             Teller::String __stdcall IndexingHTMLRequest(Teller controlID); // assuming the Teller holds an HTML POST or GET Request, the string for control controlID is returned using Indexing. for "B1=123123&T1=wqeqwe" - IndexingHTMLRequest("T1") == "wqewqe".
             Teller& __stdcall EncodeBase64(char* buffer, int len); // encode the buffer using Base64 and add it to the string. retval is *this.
             Teller& __stdcall AsXoredWith(Teller::String buffer, Teller& retbuff=Teller());    // rets retbuff with any char in the msgOut xored with a char in the input buffer rolling over. retbuff may contain '\0', retbuff.Len() is this->Len(); Recommended to recover '\0' chars for example by using SourceSyntax(). 
             Teller& __stdcall HTMLLowerTagsCase();                 // (HTML) Lowercase only the tags between '<' and '>';
             Teller& __stdcall RTLReading();                        // MessageBox MB_RIGHT|MB_RTLREADING
             Teller& __stdcall LTRReading();                        // MessageBox ~(MB_RIGHT|MB_RTLREADING)
          static Teller::String __stdcall ModuleFileName();         // GetModuleFileName();
          static Teller::String __stdcall ModuleRootFolder();       // GetModuleFileName() without "\filename.exe", ends without '\\'
          static Teller::String __stdcall DefaultPath();            // GetCurrentDirectory(); // no '\\' terminating. (tested XP).
          static Teller::String __stdcall CgiScriptHeader();        // Retval is "Content-type: text/plain\n\n";
          static Teller::String __stdcall LastErrorString(DWORD error=GetLastError()); // GetLastError() - FormatMessage
          virtual Teller& __stdcall operator<<(Teller& tll);        // set at march 2001, but not in use.
             Teller& __stdcall operator<<(Teller::String rst);      // set at jan 2003.
             Teller& __stdcall operator>>(Teller& tll);
             Teller& __stdcall operator<<(const StrAdd sta);
             Teller& __stdcall operator=(Teller&);                  // this was added 25/06/2002.
             Teller& __stdcall operator=(Teller::String& rts);      // this was added 26/01/2003. // fixed to (Teller::String& rts) from (Teller::String rts) 5/12/2003 (VC++ conversion)
             Teller& __stdcall operator=(char* str);                // this was added 29/12/2002. // so won't Clear() self when tll<<tll.Str();
             bool __stdcall Swap(Teller& tlr);                      // Swap both char*'s, so that no need to copy back from temp Teller.
             bool __stdcall Copy(Teller& tlr);                      // Copy ignoring indexes. added 29-11-2003.
  #if ((!defined(__BORLANDC__))||(__BORLANDC__>=0x0550)) // other wise as global function at the end.
          template <class chType> Teller& operator>>(chType* str);   // notice the specific for char* next line. this was added 6/10/2001.
          template <class tType> Teller& operator=(tType param);     // this was added 11/10/2001.
          template <class tType> Teller& operator<<(tType* rpFunc);  // added 24-10-2001. Asaf Shelly.
// Compiler loops internally!!! 24-10-2001 template <class cfType> Teller& Teller::operator<<(cfType __closure* pFunc); // this has no implementation in BC5.02 Added 24-10-2001 Asaf Shelly.
  #endif
             Teller& __stdcall operator>>(char* str);
             unsigned long __stdcall ValidInteger();                // Valid digits including +/- sign
             Teller& __stdcall operator>>(long &lng);
             unsigned long __stdcall ValidUnsigned();               // Valid digits 0 if +/- sign
             Teller& __stdcall operator>>(unsigned int &uintgr);
             Teller& __stdcall operator>>(unsigned long &ulng);
   #ifndef _WIN32_WCE
             Teller& __stdcall operator>>(FILE* fp);
             Teller& __stdcall operator<<(FILE* fp);
   #endif // _WIN32_WCE
             char* __stdcall operator>>(const StrRet it);
             char* __stdcall operator<<(const StrRet it);
             char* __stdcall operator()(const StrRet it);
             Teller& __stdcall operator()(char* strs, char* stre=NULL);      // str start, str end.
             Teller& __stdcall operator()(Teller& tlr);
             Teller& __stdcall operator()(Teller& tlrs, Teller& tlre);       // Teller start, Teller end.
             Teller& __stdcall operator[](const unsigned long count);        // NOTE, when using a for loop, mind that items passed last index are ignored, so start the loop from -1, not from 0. NOTE, better for runtime to use 0 and advance using IndexingNext(). 
             unsigned long __stdcall Count();                                // retval is intances found of (*this)("<TEXT>").
             unsigned long __stdcall IndexCount() { return(Count()); }                                
             Teller& __stdcall operator<<(const Rotator rot);
             Teller& __stdcall operator>>(const Rotator rot);
             Teller& __stdcall operator<<(const Insertor ins);
             Teller& __stdcall operator>>(const Insertor ins);
             int __stdcall RotateStr(int count);
             Teller& __stdcall operator<<(IntType it);
             Teller& __stdcall operator<<(char* str);
             Teller& __stdcall operator<<(const char* str);
             Teller& __stdcall operator<<(const unsigned char c);
             Teller& __stdcall operator>>(unsigned char &c);
             Teller& __stdcall operator<<(const bool b);
             Teller& __stdcall operator>>(bool &b);
             Teller& __stdcall operator<<(char c);
             Teller& __stdcall operator<<(const int i);
             Teller& __stdcall operator>>(int &intgr);
             Teller& __stdcall operator<<(unsigned int u);
             Teller& __stdcall operator<<(long l);
             Teller& __stdcall operator<<(unsigned long ul);
             Teller& __stdcall operator<<(const __int64 i64);
             Teller& __stdcall operator>>(__int64 &i64);
             Teller& __stdcall operator<<(const unsigned __int64 u64);
             Teller& __stdcall operator>>(unsigned __int64 &u64);
             Teller& __stdcall operator<<(const double e);
             Teller& __stdcall operator>>(double &e);
             Teller& __stdcall operator<<(const wchar_t* wstr);
             Teller& __stdcall operator<<(wchar_t* wstr) { return((*this)<<((const wchar_t*)wstr)); }
             Teller& __stdcall operator>>(wchar_t* wstr);
             Teller& __stdcall operator>>(const wchar_t* wstr) { return((*this)>>((wchar_t*)wstr)); }
             Teller& __stdcall operator<<(void* vp);
             Teller& __stdcall operator<<(POINT pt);
             Teller& __stdcall operator<<(GUID guid);
             Teller& __stdcall operator<<(LPCITEMIDLIST pidl);
             Teller& __stdcall operator>>=(char* str);              // Send to a Double NULL string.
             Teller& __stdcall operator<<=(char* str);              // Read from a Double NULL string.
             bool __stdcall operator==(Teller& tll);
             bool __stdcall operator==(Teller::String& str);
             bool __stdcall operator==(const char* str);
             bool __stdcall operator!=(Teller& tll);
             bool __stdcall operator!=(const char* str);
             Teller __stdcall operator+(Teller tll);                // WARNING : Bad realtime.
          static int __stdcall ConvertToFileName(int ch);
  #ifdef DSTRING_H // VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL
             Teller& __stdcall operator<<(AnsiString& astr) { return((*this)<<astr.c_str()); }
             Teller& __stdcall operator=(AnsiString& astr) { return((*this)<<astr.c_str()); }
  #endif // VCL_H // VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL
  #ifdef _MANAGED // MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - 
             Teller& __stdcall operator<<(System::String* pgcstr);
             Teller& __stdcall operator=(System::String* pgcstr);
             Teller& __stdcall operator==(System::String* pgcstr);
             Teller& __stdcall operator>>(System::String*& prgcstr);
             //__stdcall operator System::String __gc*();
  #endif _MANAGED // MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - MANAGED CPP - 
             Teller& __stdcall operator<<(RECT &rct);
  };

 bool __import __stdcall operator==(char* str, Teller& tll);
 Teller __import __stdcall operator+(char* str, Teller tll);   // WARNING : Very Bad realtime. (FlagsSetTemporaryMaySwap() not set here).

 class __LINKAGE_WMD teller_: public Teller     // compatibility 02/12/2002
  {
   private:
   protected:
   public:
             teller_(char* info, int oMedia);
             teller_();
  };
                                           // compatibility 02/12/2002



   #if (__LINKAGE_WMD_TYPE=='L') || defined(__WMD_OSTYPE_WIN9X__)
   
 extern Teller Tell;
 extern Teller Ods;
 extern Teller& tell;
 extern Teller& dView_;    // compatibility.

   #elif ((__LINKAGE_WMD_TYPE=='I')||(__LINKAGE_WMD_TYPE=='E')) // 10/8/2004 corrected from #else if
   
 Teller __import Tell;
 Teller __import Ods;
 
      #ifndef _MSC_VER
 Teller& __import tell;
 Teller& __import dView_;  // compatibility.
      #endif //_MSC_VER

 ThreadUnique<Teller> __import __Tell_ThreadUnique;
 ThreadUnique<Teller> __import __Ods__ThreadUnique;

   #else // 10/8/2004

 ThreadUnique<Teller> __import __Tell_ThreadUnique;
 ThreadUnique<Teller> __import __Ods__ThreadUnique;
   
   #endif


//////////////////////////////////////////////////////////////////////////////////////////////////

  #if ((!defined(__BORLANDC__))||(__BORLANDC__>=0x0550))

  template <class chType>
 Teller& Teller::operator>>(chType* str)
  {
   if ((!this)||(!msgOut))
    {
     if (str) str[0]=0;
     return(*this);
    }
   if (str!=NULL) STRcpy(str,msgOut);
   msgOut[0]=0;
   return(*this);
  }

  template <class tType>
 Teller& Teller::operator=(tType param)
  {
   Clean();
   return((*this)<<param);
  }

  template <class tType>
 Teller& Teller::operator<<(tType* rpFunc)
  {
   return((*this)<<(*((void**)&rpFunc)));
  }

/* Compiler loops forever 24-10-2001 template <class cfType>
Teller& Teller::operator<<(cfType __closure* pFunc)
{
return((*this)<<(*((void**)rpFunc)));
}
*/
  #else // ((!defined(__BORLANDC__))||(__BORLANDC__>=0x0550))

  template <class chType>
 Teller& operator>>(Teller& tll, chType* str)
  {
   if (&tll) { if (str) str[0]=0;  return(tll); }
   if (str!=NULL) STRcpy(str,tll(tll.str));
   tll.Clean();
   return(tll);
  }

  template <class tType>
 Teller& operator=(Teller& tll, tType param)
  {
   tll.Clean();
   return(tll<<param);
  }

  template <class tType>
 Teller& operator<<(Teller& tll, tType* rpFunc)
  {
   return(tll<<(*((void**)rpFunc)));
  }

  #endif // ((!defined(__BORLANDC__))||(__BORLANDC__>=0x0550)) - else

//////////////////////////////////////////////////////////////////////////////////////////////////












} using namespace StdTell_namespace;


  #ifdef VCL_H // VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL

/* AnsiString __stdcall operator=(AnsiString astr, Teller& rtl)
{
astr=rtl.Str();
return(astr);
}

AnsiString& __stdcall operator=(AnsiString &astr, Teller::String& rts)
{
astr=trs.Str();
return(astr);
}
*/
  #endif // VCL_H // VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL VCL



//////////////////////////////////////////////////////////////////////////////////////////////////


 #endif // ndef INCLUDE_FILE__stdTell_h__